package com.ruoyi.io;
import java.io.*;

public class OutputStreamWriterExample {
    public static void main(String[] args) {
        FileOutputStream outputStream = null;
        OutputStreamWriter writer = null;

        try {
            outputStream = new FileOutputStream("E:\\output.txt");
            writer = new OutputStreamWriter(outputStream, "UTF-8");
            writer.write("Hello World!1111");
            writer.close();
        } catch (IOException e) {
            System.out.println("Error: " + e.getMessage());
        } finally {
            try {
                if (writer != null)
                    writer.close();
                if (outputStream != null)
                    outputStream.close();
            } catch (IOException e) {
                System.out.println("Error: " + e.getMessage());
            }
        }
    }
}
